<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="../style.css">
    <link rel="icon" href="./jmicro.png">
    <script type="text/javascript" src="../js/rpc.js"></script>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <title>Test Base64</title>
    <style>

    </style>
</head>
<body>
<div id="msg" style="color:red;"></div>

<div class="JTestingPubsub" id="testing">

    <div>
        <Button onclick="doEncode()">encode</Button><br/>
        <label for="ec">Encode Content</label>
        <Input id="ec"   value="abc"/>
        <br/>

        <textarea id="encryptResult">
        </textarea>
    </div>

    <div>
        <Button onclick="doDecode()">Decode</Button><br/>
        <textarea id="decryptResult">
        </textarea>
    </div>

</div>
</body>

<script  type="text/javascript">

    $(function(){
        jm.config.sslEnable = false;
        jm.rpc.init({ip: "localhost",port:9090});
    })

    function doEncode(){
        let raa  = jm.utils.toUTF8Array($('#ec').val());
        let rst = jm.utils.byteArr2Base64(raa);
        $('#encryptResult').val(rst);
    }

    function doDecode() {
        let arr = jm.utils.base642ByteArr($('#encryptResult').val());
        let str = jm.utils.fromUTF8Array(arr);
        $('#decryptResult').val(str);
    }

</script>
</html>
